﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Common;
using FarseerPhysics.Collision.Shapes;
using FarseerPhysics.Factories;
using FarseerPhysics;

namespace chemicall
{
    public class SimulatePause
    {
        // imitation de GameTime
        private TimeSpan totalRealTime;
        private TimeSpan totalGameTime;
        private TimeSpan elapsedRealTime;
        private TimeSpan elapsedGameTime;
        private bool isRunningSlowly;
        public GameTime realTime;

        // gestion de la pause
        private TimeSpan gameTimePause = TimeSpan.Zero;
        private TimeSpan realTimePause = TimeSpan.Zero;
        private bool paused = false;     

        // propriétés
        public bool Paused 
        { 
            get { return paused; } 
            set { paused = value; } 
        }

        public TimeSpan TotalRealTime
        {
            get { return realTime.TotalGameTime - realTimePause; }
        }

        public TimeSpan TotalGameTime
        {
            get { return realTime.TotalGameTime - gameTimePause; }
        }

        public TimeSpan ElapsedGameTime 
        { 
            get { return elapsedGameTime; } 
        }

        public TimeSpan ElapsedRealTime 
        { 
            get { return elapsedRealTime; } 
        }

        public bool IsRunningSlowly 
        { 
            get { return isRunningSlowly; } 
        }

        public void Update(GameTime systemTime)
        {
            // première initialisation - rien d'aurte à faire
            totalRealTime = TotalRealTime;
            totalGameTime = systemTime.TotalGameTime;
            elapsedRealTime = ElapsedRealTime;
            elapsedGameTime = systemTime.ElapsedGameTime;
            isRunningSlowly = systemTime.IsRunningSlowly;

            if (paused)
            {
                gameTimePause = gameTimePause + elapsedGameTime;
                realTimePause = realTimePause + elapsedRealTime;
            }
        }
    }
}
